#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
string t, s, z;
int n;
int main()
{
	cin >> n;
	cin >> t;
	bool flag = 0;
	string m = "0123456789ABCDEF";
	for (int i = 2; i <= 16; i++) {
		s = "";
		for (int j = n; j >= 1; j--) {
			int k = j;
			while (k) {
				s.push_back(m[k % i]);
				k /= i;
			}
		}
		reverse(s.begin(), s.end());
		cout << s << endl;
		if (s.find(t) != -1) {
			flag = 1;
			break;
		}
	}
	if (flag) {
		cout << "yes" << endl;
	}
	else {
		cout << "no" << endl;
	}
	return 0;
}